<template>
    <div>
        <h1>病房显示</h1>
        所属科室<select v-model="info.ksid">
            <option value="">请选择</option>
            <option :value="itme.Id" v-for="itme in lisr" :key="itme.Id">{{ itme.Name }}</option>
        </select>
        病房名称 <input type="text" v-model="info.fjname">
        <input type="button" value="查询" @click="getlist">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>Id</td>
                    <td>房间号</td>
                    <td>病房名称</td>
                    <td>所属科室</td>
                    <td>床位总数量</td>
                    <td>人数状态</td>
                    <td>病房状态</td>
                    <td>空闲床数量</td>
                    <td>创建日期</td>
                    <td>操作</td>
                </tr>

                <tr v-for="itme in data.list">
                    <td>{{ itme.Id }}</td>
                    <td>{{ itme.FJH }}</td>
                    <td>{{ itme.FJHName }}</td>
                    <td>{{ itme.KSId }}</td>
                    <td>{{ itme.NuMber }}</td>
                    <td>{{ itme.Strte == true ? "已满" : "未满" }}</td>
                    <td>{{ itme.State == true ? "启用" : "维修" }}</td>
                    <td>{{ itme.KX }}</td>
                    <td>{{ itme.ConTime }}</td>
                    <td>
                        <input type="button" value="启用" @click="xg(itme.Id, true)">
                        <input type="button" value="维修" @click="xg(itme.Id, false)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
let info: any = reactive({
    ksid: '',
    fjname: ''
})
let data: any = reactive({
    list: []
})
let lisr: any = ref([]);
onMounted(() => {
    getlist();
    getlisr();
})
const getlist = () => {
    axios({
        url: '/api/BF/BFList',
        method: 'get',
        params: info
    })
        .then((res) => {
            console.log(res);
            data.list = res.data

        })
        .catch((err) => {
            console.log(err);

        })
}
//==========================================下拉框查询
const getlisr = () => {
    axios({
        url: '/api/KS/KSShow',
        method: 'get',

    })
        .then((res) => {
            console.log(res);
            lisr.value = res.data
        })
        .catch((err) => {
            console.log(err);

        })
}
//================================修改状态
const xg = (id: any, state: any) => {
    axios({
        url: '/api/BF/XG',
        method: 'get',
        params: {
            id: id,
            state: state,
        }

    })
        .then((res) => {
            console.log(res);
            console.log(res);
            if (res.data > 0) {
                alert("修改成功");
                getlist();
                return;
            }
            else {
                alert("修改失败");
                return;
            }

        })
}
</script>

<style scoped></style>